package com.hanserwei.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {
    @Bean
    public FanoutExchange fanoutExchange() {
        return new FanoutExchange("order.fanout");
    }

    @Bean
    public Queue orderQueueOne() {
        return new Queue("order.queue.one");
    }

    @Bean
    public Queue orderQueueTwo() {
        return new Queue("order.queue.two");
    }

    @Bean
    public Binding bindingOne(FanoutExchange fanoutExchange, Queue orderQueueOne) {
        return BindingBuilder.bind(orderQueueOne).to(fanoutExchange);
    }

    @Bean
    public Binding bindingTwo(FanoutExchange fanoutExchange, Queue orderQueueTwo) {
        return BindingBuilder.bind(orderQueueTwo).to(fanoutExchange);
    }
}
